package com.jy.event.domain;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;

/**
 * Created by hanxi on 2017/7/17.
 */
@Entity
@Data
@NoArgsConstructor
public class OrderItem {
    @Id
    @Column(length = 50)
    private String id;
    private String productName;
    private String productId;
    private String productImageURL;
    private String productTypeId;
    private double salesPrice = 0;

    private double dealPrice = 0;

    private double costPrice = 0;
    private int quantity = 0;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3)")
    private Date addTime;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)")
    private Date updateTime;
    /**
     * 固定提成金额
     */
    private double commission = 0;
    /**
     * 是否支持厨房打印
     */
    private boolean kitchenPrintEnabled = false;

    public OrderItem(String id, Product product,
                     double salesPrice, double dealPrice, int quantity,
                     double commission) {
        this.id = id;
        this.productName = product.getName();
        this.productId = product.getId();
        this.salesPrice = salesPrice;
        this.dealPrice = dealPrice;
        this.quantity = quantity;
        this.commission = commission;
        this.productImageURL = product.getImageURL();
        this.productTypeId = product.getProductType().getId();
    }

    public OrderItem(String id, String productId, String productName,
                     double salesPrice, double dealPrice, int quantity,
                     double commission, String productImageURL) {
        this.id = id;
        this.productName = productName;
        this.productId = productId;
        this.salesPrice = salesPrice;
        this.dealPrice = dealPrice;
        this.quantity = quantity;
        this.commission = commission;
        this.productImageURL = productImageURL;
    }
}
